//
//  Pic.m
//  Echo
//
//  Created by Liao on 14/12/16.
//  Copyright (c) 2014年 sina. All rights reserved.
//

#import "Pic.h"
#import "ApiConfig.h"

@interface Pic ()
+ (NSString *)getUrlFromPid:(NSString *)pid WithType:(NSString *)type;

@end

@implementation Pic

@synthesize pid = _pid;
@synthesize url = _url;

- (instancetype)initWithPid:(NSString *)pid {
    self = [super init];
    if (!self) {
        return nil;
    }
    _pid = pid;
    _url = [Pic getUrlFromPid:_pid WithType:DEFAULT_PIC_TYPE];
    return self;
}

+ (NSString *)getUrlFromPid:(NSString *)pid WithType:(NSString *)type {
    int num = arc4random_uniform(4) + 1;
    NSString *url = [NSString stringWithFormat:PIC_URL_BASE, [NSNumber numberWithInt:num], type, pid];
    return url;
}

@end
